<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="theme/style.css"
	media="screen" />
<title>OES - Signup</title>
<script language="javascript">
	function userfocus() 
	{
		document.fm.userName.focus();
	}
	
	function emailValidation()
	{
		var emailValue = document.getElementByName("emailId").value;
		alert(emailValue);
		var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
		if(!emailValue.match(emailExp) || emailValue=="" )
		{
			alert("Please enter valid email.");
			document.getElementByName("emailId").focus();
			return false;
		}
		else
		{
			return true;
		}
	}


	function check() 
	{
		var userID,pwd,confPwd,fname,lname,email,ph,addr1,addr2,city,state,country,SecAns;
		userID = document.fm.userName.value;
		pwd = document.fm.password.value;
		confPwd = document.fm.confirmPassword.value;
		fname = document.fm.firstName.value;
		lname = document.fm.lastName.value;
		email = document.fm.emailId.value;
		ph = document.fm.phone.value;
		addr1 = document.fm.add1.value;
		addr2 = document.fm.add2.value;
		city = document.fm.city.value;
		state = document.fm.state.value;
		country = document.fm.country.value;
		secAns = document.fm.securityAnswer.value;

		if (userID.length < 1) 
		{
			alert("You must enter User Name");
			document.fm.userName.focus();
			return false;
		} else if (pwd.length < 1) 
		{
			alert("You must enter Password");
			document.fm.password.focus();
			return false;
		}
		else if (confPwd.length < 1) 
		{
			alert("You must enter Confirmation Password");
			document.fm.confirmPassword.focus();
			return false;
		}
		else if(pwd != confPwd)
		{
			alert("New password and confirm password should be same");
			document.fm.password.value = "";
			document.fm.confirmPassword.value = "";
			document.fm.password.focus();
			return false;
		}else if(fname.length<1)
		{
			alert("You must enter first name.");
			document.fm.firstName.focus();
			return false;
		}else if(lname.length<1)
		{
			alert("You must enter last name.");
			document.fm.lastName.focus();
			return false;
		}
		else if(email.length<1)
		{
			alert("You must enter email id.");
			document.fm.emailId.focus();
			return false;
		}
		else if(ph.length<1)
		{
			alert("You must enter phone.");
			document.fm.phone.focus();
			return false;
		}
		else if(addr1.length<1)
		{
			alert("You must enter address.");
			document.fm.add1.focus();
			return false;
		}
		else if(addr2.length<1)
		{
			alert("You must enter address.");
			document.fm.add2.focus();
			return false;
		}
		else if(city.length<1)
		{
			alert("You must enter city.");
			document.fm.city.focus();
			return false;
		}
		else if(state.length<1)
		{
			alert("You must enter state.");
			document.fm.state.focus();
			return false;
		}
		else if(country.length<1)
		{
			alert("You must enter country.");
			document.fm.country.focus();
			return false;
		}
		else if(secAns.length<1)
		{
			alert("You must enter Security Answer.");
			document.fm.securityAnswer.focus();
			return false;
		}
		return true;
	}
</script>
</head>
<body onload="userfocus()">
	<div id="MainWrapper">
		<jsp:include page="header.jsp" /> 
		<jsp:include page="LeftContainer.jsp" />
		<div id="MainContent">
		<h2>User Registration</h2>
			<form action="Register.do" method="post" name="fm" onsubmit="return check()" onreset="userfocus()">
				<table>
					<tr><td>User Name: </td><td></td><td><input type="text" name="userName"/></td></tr>
					<tr><td>Password: </td><td></td><td><input type="password" name="password"/></td></tr>
					<tr><td>Confirm Password: </td><td></td><td><input type="password" name="confirmPassword"/></td></tr>
					<tr><td>First Name: </td><td></td><td><input type="text" name="firstName"/></td></tr>
					<tr><td>Last Name: </td><td></td><td><input type="text" name="lastName"/></td></tr>
					<tr><td>Email ID: </td><td></td><td><input type="text" name="emailId" onblur="return emailValidation()"/></td></tr>
					<tr><td>Phone Number: </td><td></td><td><input type="text" name="phone"/></td></tr>
					<tr><td>Address1: </td><td></td><td><input type="text" name="add1"/></td></tr>
					<tr><td>Address2: </td><td></td><td><input type="text" name="add2"/></td></tr>
					<tr><td>City: </td><td></td><td><input type="text" name="city"/></td></tr>
					<tr><td>State: </td><td></td><td><input type="text" name="state"/></td></tr>
					<tr><td>Country: </td><td></td><td><input type="text" name="country"/></td></tr>
					<tr><td>Security Question: </td><td></td><td><select name="securityQuestion">
						<option>Who is your Childhood hero?</option>
						<option>Where did you born?</option>
						<option>In what city or town was your first job?</option>
						<option>What is your first phone number?</option>
						<option>What is your favorite car?</option>
						<option>What is your mother's middle name?</option>
						<option>What is your childhood nickname?</option>
						<option>What is your first school you studied?</option>
					</select>
					</td></tr>
					<tr><td>Security Answer: </td><td></td><td><input type="password" name="securityAnswer"/></td></tr>
					<tr></tr>
					<tr><td></td><td><input type="submit" name="submit" value="Submit"/>
					<input type="reset" value="Reset"></td></tr>
				</table>
			</form>
		</div>
		<jsp:include page="footer.jsp" />
	</div>
</body>
</html>